package hot100.logos61To70;

/**
 * @author logos
 * date 2025/7/16 12:56
 * @version v1.0
 * @Package hot100.logos61To70
 */
public class logos63 {

    /**
     * 63. 搜索插入位置
     * https://leetcode.cn/problems/search-insert-position/?envType=study-plan-v2&envId=top-100-liked
     */

    class Solution {
        public int searchInsert(int[] nums, int target) {
            int left = 0;
            int right = nums.length - 1;
            while (left <= right) {
                int mid = left + (right - left) / 2;
                if (nums[mid] >= target) {
                    right = mid - 1;
                } else {
                    left = mid + 1;
                }
            }
            return left;
        }
    }
}
